Options:
-h, --help Print this message
--vcs VCS Initialize a new repository for the given version
- control system (git, hg, or pijul) or do not initialize any version
- control at all (none) overriding a global configuration.
+ control system (git, hg, pijul, or fossil) or do not
+ initialize any version control at all (none), overriding
+ a global configuration.
--bin Use a binary (application) template
--lib Use a library template [default]
--name NAME Set the resulting package name, defaults to the value of <path>
use core::Workspace;
use ops::is_bad_artifact_name;
-use util::{GitRepo, HgRepo, PijulRepo, internal};
+use util::{GitRepo, HgRepo, PijulRepo, FossilRepo, internal};
use util::{Config, paths};
use util::errors::{CargoError, CargoResult, CargoResultExt};
use toml;
#[derive(Clone, Copy, Debug, PartialEq)]
-pub enum VersionControl { Git, Hg, Pijul, NoVcs }
+pub enum VersionControl { Git, Hg, Pijul, Fossil, NoVcs }
pub struct NewOptions<'a> {
pub version_control: Option<VersionControl>,
"git" => VersionControl::Git,
"hg" => VersionControl::Hg,
"pijul" => VersionControl::Pijul,
+ "fossil" => VersionControl::Fossil,
"none" => VersionControl::NoVcs,
n => {
let err = format!("could not decode '{}' as version control", n);
num_detected_vsces += 1;
}
+ if fs::metadata(&path.join(".fossil")).is_ok() {
+ version_control = Some(VersionControl::Fossil);
+ num_detected_vsces += 1;
+ }
+
// if none exists, maybe create git, like in `cargo new`
if num_detected_vsces > 1 {
- bail!("more than one of .hg, .git, or .pijul directories found \
- and the ignore file can't be \
- filled in as a result, \
- specify --vcs to override detection");
+ bail!("more than one of .hg, .git, .pijul, .fossil configurations \
+ found and the ignore file can't be filled in as \
+ a result. specify --vcs to override detection");
}
}
PijulRepo::init(path, config.cwd())?;
}
},
+ VersionControl::Fossil => {
+ if !fs::metadata(&path.join(".fossil")).is_ok() {
+ FossilRepo::init(path, config.cwd())?;
+ }
+ },
VersionControl::NoVcs => {
fs::create_dir_all(path)?;
},
use std::path::Path;
+use std::fs::create_dir;
use git2;
pub struct HgRepo;
pub struct GitRepo;
pub struct PijulRepo;
+pub struct FossilRepo;
impl GitRepo {
pub fn init(path: &Path, _: &Path) -> CargoResult<GitRepo> {
Ok(PijulRepo)
}
}
+
+impl FossilRepo {
+ pub fn init(path: &Path, cwd: &Path) -> CargoResult<FossilRepo> {
+ // fossil doesn't create the directory so we'll do that first
+ create_dir(path)?;
+
+ // set up the paths we'll use
+ let db_fname = ".fossil";
+ let mut db_path = path.to_owned();
+ db_path.push(db_fname);
+
+ // then create the fossil DB in that location
+ process("fossil").cwd(cwd).arg("init").arg(&db_path).exec()?;
+
+ // open it in that new directory
+ process("fossil").cwd(&path).arg("open").arg(db_fname).exec()?;
+
+ // set `target` as ignoreable and cleanable
+ process("fossil").cwd(cwd).arg("settings")
+ .arg("ignore-glob")
+ .arg("target");
+ process("fossil").cwd(cwd).arg("settings")
+ .arg("clean-glob")
+ .arg("target");
+ Ok(FossilRepo)
+ }
+}